import { createRouter, createWebHashHistory } from 'vue-router'
import home from '../layout/index.vue'

const routes: any = [
  {
    path: '/:catchAll(.*)', // 不识别的path自动匹配404
    component: () => import('../views/error/404/index.vue'),
  },
  {
    path: '/',
    component: home,
    redirect: '/cvmagic/dashboard/workplace',
    children: [
      {
        path: '/cvmagic/dashboard',
        title: '仪表盘',
        component: () => import('@/views/dashboard/index.vue'),
        children: [
          {
            path: '',
            title: '数据',
            meta: {
              title: '数据',
            },
            component: null,
            children: [
              {
                path: '/cvmagic/dashboard/workplace',
                meta: {
                  title: '工作台',
                },
                title: '工作台',
                component: () =>
                  import('@/views/dashboard/workplace/index.vue'),
              },
            ],
          },
        ],
      },

      {
        path: '/cvmagic/system',
        title: '超级管理员',
        meta: {
          title: '超级管理员',
        },
        component: () => import('@/views/dashboard/index.vue'),
        children: [
          {
            path: '',
            title: '权限',
            meta: {
              title: '权限',
            },
            component: null,
            children: [
              {
                path: '/cvmagic/system/role',
                title: '角色管理',
                meta: {
                  title: '角色管理',
                },
                component: () => import('@/views/system/role/index.vue'),
              },
              {
                path: '/cvmagic/system/user',
                title: '用户管理',
                meta: {
                  title: '用户管理',
                },
                component: () => import('@/views/system/user/index.vue'),
              },
            ],
          },
        ],
      },
    ],
  },

  {
    path: '/cvmagic/login',
    title: '登入',
    component: () => import('@/views/login/index.vue'),
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

export default router
